<script setup>
import { useResumeStore } from '@/stores/resume'
import { useRouter } from 'vue-router'
const router = useRouter()
const {createResume} = useResumeStore()
const props = defineProps({
  cardData:{
    type: Object,
    default: () => {
      return {
        style: '标题',
        url: '/modern.webp',
        desc:'描述'
      }
    },
  }
})
const win = window
</script>

<template>
<div class="card-main">
    <div class="card-header">
        <div class="card-style">{{ cardData.style }}</div>
    </div>
    <div class="card-body">
        <div class="card-url">
            <img :src="cardData.url" alt="简历" class="card-img"></img>
        </div>
    </div>
    <div class="card-footer">
        <div class="card-header-btn">
            <el-button plain @click.stop="win.open(cardData.url, '_blank')">预览</el-button>
            <el-button type="primary"       @click="()=>{
            createResume(cardData)
            router.push('/home/myResume')
        }">使用此模板</el-button>
        </div>
    </div>
    <div class="card-desc">{{ cardData.desc }}</div>
    <div class="card-mark"></div>
</div>
</template>

<style scoped>
.card-mark{
    width: 300px;
    height: 430px;
    position: absolute;
    z-index: 10;
    top: 0;
    left: 0;
    background-image: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0))
;
    opacity: 0;
    transition: 0.2s linear;
}
.card-main:hover .card-mark{
    opacity: 0.5;
}
.card-main:hover .card-url{
    transform: scale(1.02);

}
.card-main:hover .card-desc{
    transform: translateY(-80px);

}
.card-desc{
    position: absolute;
    bottom: 0;
    left: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s linear;
    z-index: 11;
    color: rgb(198, 198, 198);
    width: 280px;
}
.card-main{
    display: flex;
    flex-direction: column;
    width: 300px;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
   position: relative;
   background-color: rgb(17, 24, 39);
    overflow: hidden;
    margin-top: 20px;
    
}
.card-style{
    position: absolute;
    padding: 6px 12px;
    background-color: rgba(31, 41, 55, 0.9);
    border: 1px rgb(55, 65, 81) solid;
    font-size: 12px;
    right: 0;
    top: 0;
    border-radius: 0 10px;
    border-top: none;
    border-right: none;
}
.card-url{
    display: flex;
    justify-content: center;
    align-items: center;
    width: 300px;
    height: 400px;
    padding-top: 20px;
   transition: 0.2s linear;
   margin-bottom: 10px;
}
.card-img{
    width: 286px;
    
}
.card-header-btn{
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 300px;
    padding: 20px 0;
    background-color: rgb(3, 7, 18);
    z-index: 20;
    position: relative;
}
.card-header-btn button{
    width: 40%;
    height: 36px;

}
</style>
